package com.darwin.darwinNet
{
	import flash.net.URLRequest;
	import flash.net.URLRequestHeader;
	
	/**
	 * HttpRequest
	 * 可获取 post/get/文件流 请求 
	 * @author vanCopper
	 * 
	 */	
	public class HttpRequest
	{
		public function HttpRequest()
		{
		}
		
		/**
		 * 获取Post请求的URLRequest 
		 * @param reqUrl
		 * @return 
		 * 
		 */		
		public static function getPostRequest(reqUrl:String):URLRequest
		{
			if(!reqUrl){return null;};
			var urlRequest:URLRequest = new URLRequest(reqUrl);
			urlRequest.method = Net.HTTP_POST;
			return urlRequest;
		}
		
		/**
		 * 获取Get请求的URLRequest 
		 * @param reqUrl
		 * @return 
		 * 
		 */		
		public static function getGetRequest(reqUrl:String):URLRequest
		{
			if(!reqUrl){return null;};
			var urlRequest:URLRequest = new URLRequest(reqUrl);
			urlRequest.method = Net.HTTP_GET;
			return urlRequest;
		}
		
		/**
		 * 获取用于发送二进制文件的URLRequest 
		 * URLRequest.data 应为要发送的二进制数据
		 * @param reqUrl
		 * @return 
		 * 
		 */		
		public static function getFileRequest(reqUrl:String):URLRequest
		{
			if(!reqUrl){return null;}
			var urlRequest:URLRequest = new URLRequest(reqUrl);
			var header:URLRequestHeader = new URLRequestHeader("Content-type","application/octet-stream");
			urlRequest.requestHeaders.push(header);
			urlRequest.method = Net.HTTP_POST
			return urlRequest;
		}

	}
}